package com.guigu.wenzhiyi.controller;

import com.github.pagehelper.PageInfo;
import com.guigu.liuyunan.pojo.Meals;
import com.guigu.liuyunan.pojo.Sportsitemlibrary;
import com.guigu.wenzhiyi.pojo.Scheme;
import com.guigu.wenzhiyi.service.SchemeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("Scheme")
public class SchemeController {

    @Autowired
    SchemeService schemeService;

    @RequestMapping("page")
    public PageInfo<Scheme> page(Integer num, Integer size, String name){
        return schemeService.page(num,size,name);
    }

    @RequestMapping("pagecha")
    public List<Scheme> pagecha(String name){
        return schemeService.pagecha(name);
    }

    @RequestMapping("mpage") // 饮食
    public PageInfo<Meals> mpage(Integer num, Integer size, String name){
        return schemeService.MPageCha(num,size,name);
    }
    @RequestMapping("spage") // 运动
    public PageInfo<Sportsitemlibrary> spage(Integer num, Integer size, String name){
        return schemeService.SPageCha(num,size,name);
    }

    @RequestMapping("add")
    public int add(@RequestBody Scheme scheme){
        return schemeService.add(scheme);
    }

    @RequestMapping("delete")
    public int delete(Integer id){
        return schemeService.delete(id);
    }

    @RequestMapping("update")
    public int update(@RequestBody Scheme scheme){
        return schemeService.update(scheme);
    }



}
